<template>
  <el-card class="inforcard">
    <div class="cbox1">
      <p class="nickname" :style="{'--themecolor':themeActive}">Hi，{{ user.userName }}</p>
      <p class="accountbox">
        <img :src="require('@/assets/images/flag.png')" alt=""><span class="account">{{ user.nickName }}</span> <span v-if="postGroup" class="permission">{{ postGroup }}</span>
      </p>
      <p class="timebox" v-if="user.dept">{{ user.dept.deptName }}</p>
      <p v-if="roleGroup" class="timebox"><span>所属角色：</span><span class="time">{{ roleGroup }}</span></p>
    </div>
    <div class="cbox2">
      <el-image :src="require('@/assets/images/welcomePicture.png')" fit="fill" />
    </div>
  </el-card>
</template>
<script >
import { getUserProfile } from "@/api/system/user";
import { mapGetters, mapState } from 'vuex'
export default {
  components: {

  },
  computed: {
    themeActive() {
      return this.$store.state.settings.theme
    }
  },
  data() {
    return {
      user: {},
      roleGroup: {},
      postGroup: {},
    }
  },
  created() {
    this.getUser();
  },
  methods: {
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data;
        this.roleGroup = response.roleGroup;
        this.postGroup = response.postGroup;
      });
    }
  }
}
</script>
<style lang="scss" scoped>
  .inforcard{
    // background: url('../../assets/images/inforbg.png') 0 0 no-repeat;
    // background-size: 100% 100%;
    height: 220px;
    position: relative;
    .el-card__body {
      display: flex;
      .cbox1 {
        width: 70%;
        margin-left: 12px;
        margin-top: 4px;
        z-index: 2;
      }
      .cbox2 {
        position: absolute;
        bottom: 20px;
        right: 20px;
        z-index: 1;
        margin-left: 20px;
      }
    }
  }
  .nickname{
    font-size: 30px;
    font-weight: 500;
    margin: 10px 0;
    color: var(--themecolor);
    // background: linear-gradient(270deg, #4152EA 0%, #00AEFF 100%);
  }
  .accountbox{
    display: flex;
    align-items: center;
    margin: 20px 0;
    .account{
      font-size: 18px;
      font-weight: 500;
      color: #131414;
      margin: 0 10px;
    }
    .permission{
      max-width: 200px;
      height: 24px;
      background: linear-gradient(124deg, #3A89FF 1%, #C85AFF 100%);
      border-radius: 4px 4px 4px 4px;
      opacity: 1;
      font-size: 14px;
      font-weight: 400;
      color: #FFFFFF;
      line-height: 24px;
      text-align: center;
      overflow: hidden;
      padding: 0 8px;
    }
  }
  .timebox{
    font-size: 16px;
    font-weight: 400;
    color: #606266;
    line-height: 25px;
    overflow: hidden;
    .time{
      font-size: 16px;
      font-weight: 400;
      color: #131414;
      line-height: 20px;
    }
  }
</style>
